#!/usr/bin/python2.7
# -*- coding:utf-8 -*-

import os
import sys
import sqlite3


class Db:
    '''
    数据库操作
    '''

    # 数据库文件路径获取
    env = os.environ

    db_file = ''
    vis_root_path = '/opt/local/vis'
    try:
        vis_root_path = env['VIS_ROOT_PATH']
    except Exception, e:
        pass
    db_file = '%s/manager/data/vis.s3db' % (vis_root_path)

    def __init__(self):
        pass

    @staticmethod
    def execute(sql):
        ret = ''
        cx = sqlite3.connect(Db.db_file)
        cx.text_factory = str
        cu = cx.cursor()
        cu.execute(sql)
        cx.commit()
        ret = cu.fetchall()
        cu.close()
        cx.close()
        return ret
